<?php

class Cursosyeventos_Model extends CI_Model {
	
	public function __construct()
	{
		parent::__construct();
		$this->load->database();
	}
	
	public function get()
	{
		$query = $this->db->get('cursosyeventos');
		foreach($query->result() as $row)
		{
			if($row->type && $row->id_evento)
			{
				$temp_query = $this->db->get_where($row->type, array('id'=>$row->id_evento, 'deleted'=>0));
				$obj = $temp_query->row();
				$obj->type = $row->type;
				$result[] = $obj;
			}
			else
			{
				$result[] = (object)array('id'=>'', 'name'=>'', 'shortdesc'=>'', 'event_date'=>'', 'time'=>'', 'date'=>'', 'deleted'=>1);
			}
		}
		return $result;
	}
	
	public function get_all()
	{
		$temp_query = $this->db->get_where('cursos', array('deleted'=>0));
		$result['cursos'] = $temp_query->result();
		$temp_query = $this->db->get_where('mentoria', array('deleted'=>0));
		$result['mentoria'] = $temp_query->result();
		$temp_query = $this->db->get_where('eventos', array('deleted'=>0));
		$result['eventos'] = $temp_query->result();
		return $result;
	}
	
	public function update($input, $id)
	{
		$query = $this->db->update('cursosyeventos', $input, array('id'=>$id));
		return $query; 
	}
}

/* End of file novedades.php */
/* Location: ./application/models/novedades.php */